package com.tyao.test;

import org.apache.commons.codec.digest.DigestUtils;
import org.junit.Test;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.tyao.note.controller.UserController;
import com.tyao.note.mapper.TSUserMapper;
import com.tyao.note.model.TSUser;
import com.tyao.note.service.UserService;
import com.tyao.note.service.exception.PasswordNotMatchException;
import com.tyao.note.service.exception.UserNotFoundException;

public class testLogin {

	@Test
	public void test01() {
		AbstractApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
		TSUserMapper mapper = ac.getBean(TSUserMapper.class);
//		TSUser user = new TSUser();
//		user.setUsername("admin");
//		user.setId(4);
//		user.setPassword("admin1");
//		UserService service = ac.getBean(UserService.class);
//		System.out.println(service.getAllUser());
//		try {
////			System.out.println(service.login("admin", "admin1"));
//		} catch (Exception e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		mapper.updateState(3);
		System.out.println(mapper.confirmAdminPassword("admin"));
		ac.close();
	}
	@Test
	public void test02() {
//		AbstractApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml","springmvc.xml");
//		UserService controller = ac.getBean(UserService.class);
//		try {
//					controller.changePassword("admin1", "123456", 4);
//		} catch (PasswordNotMatchException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		ac.close();
	}
	@Test
	public void test03() {
		//String password = "admin天遥航空!";
		//password = DigestUtils.md5Hex(password);
		//System.out.println(password);
	}
}
